forked from ErickChacon/git-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-basic-code
66 lines (48 loc) · 1.6 KB
/
git-basic-code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Set up user.name for all the repositories.
git config --global user.name "Erick Chacon"
# Set up user.mail for all the repositories.
git config --global user.email "[email protected]"
# Check current user.name and user.email at once.
git config --list
# Check existing SSH keys.
ls -al ~/.ssh
# public and private key pair listed (e.g. id_rsa.pub and id_rsa)
# Generate new SSH Key
ssh-keygen -t rsa -b 4096 -C "[email protected]"
# Adding SSH key to the ssh-agent.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
# Adding the new SSH key to GitHub account.
# sudo apt-get install xclip
# xclip -sel clip < ~/.ssh/id_rsa.pub
gedit ~/.ssh/id_rsa.pub # copy the content of the file
# Set a new SHH key on your GitHub settings.
# Clone a repository.
git clone [email protected]:ErickChacon/test-2016.git
# Add a file.
git add test2
# Add all the new and modified (untracked and tracked).
git add --ignore-removal .
# Update all modified and deleted files (tracked files).
git add -u
# Add all the new, modified and removed files (untracked and tracked). #git add -A
git add .
# Check status (added and removed files).
git status
# Remove file.
git rm filename
# Commit my changes.
git commit -m "First commit"
# Pushing changes to master branch.
git push origin master
# Create new repository and push to GitHub.
echo "# First-Steps-With-Julia" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:SpeckyPeruvianStats/First-Steps-With-Julia.git
git push -u origin master
# Add .gitignore file
touch .gitignore
# Already undesired tracked file
git rm --cached filename