2013-08-22 03:34:11 +02:00
|
|
|
# To set your identify:
|
2013-08-11 21:37:11 +02:00
|
|
|
git config --global user.name "John Doe"
|
|
|
|
git config --global user.email johndoe@example.com
|
|
|
|
|
2013-09-03 13:25:16 +02:00
|
|
|
# To set your editor:
|
|
|
|
git config --global core.editor emacs
|
|
|
|
|
2013-08-22 03:34:11 +02:00
|
|
|
# To enable color:
|
2013-08-11 21:37:11 +02:00
|
|
|
git config --global color.ui true
|
2013-08-27 02:34:36 +02:00
|
|
|
|
|
|
|
# To stage all changes for commit:
|
|
|
|
git add --all
|
|
|
|
|
|
|
|
# To commit staged changes
|
|
|
|
git commit -m "Your commit message"
|
|
|
|
|
2013-10-24 06:01:42 +02:00
|
|
|
# To edit previous commit message
|
|
|
|
git commit --amend
|
|
|
|
|
2013-08-27 02:34:36 +02:00
|
|
|
# To push to the tracked master branch:
|
|
|
|
git push origin master
|
|
|
|
|
|
|
|
# To push to a specified repository:
|
|
|
|
git push git@github.com:username/project.git
|
2013-08-27 10:56:53 +02:00
|
|
|
|
2013-10-24 04:06:48 +02:00
|
|
|
# To delete the branch "branch_name"
|
|
|
|
git branch -D branch_name
|
|
|
|
|
2013-12-03 21:20:11 +01:00
|
|
|
# To see who commited which line in a file
|
|
|
|
git blame filename
|
|
|
|
|
2013-08-27 10:56:53 +02:00
|
|
|
# To sync a fork with the master repo:
|
2013-08-28 01:43:24 +02:00
|
|
|
git remote add upstream git@github.com:name/repo.git # Set a new repo
|
|
|
|
git remote -v # Confirm new remote repo
|
|
|
|
git fetch upstream # Get branches
|
|
|
|
git branch -va # List local - remote branches
|
2013-08-28 09:30:37 +02:00
|
|
|
git checkout master # Checkout local master branch
|
2013-10-24 04:06:48 +02:00
|
|
|
git checkout -b new_branch # Create and checkout a new branch
|
2013-08-28 01:43:24 +02:00
|
|
|
git merge upstream/master # Merge remote into local repo
|
2013-09-01 15:05:38 +02:00
|
|
|
git show 83fb499 # Show what a commit did.
|
2013-10-24 06:01:42 +02:00
|
|
|
git diff branch_1 branch_2 # Check difference between branches
|
2013-10-19 09:31:02 +02:00
|
|
|
git log # Show all the commits
|
|
|
|
git status # Show the changes from last commit
|