-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgitcommand.txt
More file actions
34 lines (24 loc) · 1.37 KB
/
gitcommand.txt
File metadata and controls
34 lines (24 loc) · 1.37 KB
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
git init -- initialize a repo
git add -A -- adds everything(new/modified) to staging
git add <filename> adds single file to staging
git add . --adds everything(new/modified) to staging
git commit -m "message" -- commit staged changes
git commit -am "message" -- commit from modified area without staging
git log -- get commit history on the branch
git log --oneline --graph --decorate -- to see branch history as a graph
git diff head~1..head --diff between last two commits
git diff commitid..commitid --diff between any two commits
git branch <branchname> <source> --creates branch
git checkout <branchname> -- checkout branch
git checkout -b <branchname> <source> -- create branch and checkout
git branch -d <branchname> --deletes a branch if there is no pending merges
git branch -D <branchname> --deletes a branch even if there is pending merges
git branch --all
git remote add origin <url of github repo>
git push -u origin master -- sets upstream for master and pushes master to remote
git push -- subsequent pushes from branch
git push -u origin <branchname> -- sets upstream for branch and pushes branch to remote
git fetch/git merge or git pull -- get changes from remote
git branch -d <branch name> --deletes a branch if it has no pending merges
git branch -D <branch name> --deletes a branch even if it has pending merges
git push origin :<branchname> --deletes remote branch