A bunch of my most common Git commands.
git checkout -b my_branch # Create and checkout new branch git push origin my_branch # Push to remote repo git checkout another_branch # Checkout local copy of a branch git branch # Show all branches git branch -m old_name new_name # Rename branch git branch -d branch_name # Delete after changes have been pushed git branch -D branch_name # Force delete local branch # Push own local branch to remote without merging into master or another branch git push origin local_branch_name:remote_branch_name
git fetch origin # Fetch changes from remote master, nothing applied to any branch here. # Checkout local copy of master and merge with fetched changes to master. git checkout master git merge origin/master # Checkout local copy of my branch and merge with fetched changes to master. git checkout branch_name git merge --no-ff origin/master # Run into merge conflicts? Resolve and then: git add file1.c file2.c git commit -a -m "resolved merge conflicts." # DONE.
--ff-only: Defaul, try fast-forward not preserving branching history.
--no-ff: Don't just join commits in branch and master.
git status git add some/dir git add * git commit -a -m "commit message" git push origin master git push -u origin newBranch # to push own branch to remote without merging.
git checkout my-branch git checkout another-branch path/to/file
git clone https://github.com/annis/project git pull origin
git init git remote set-url origin https://github.com/AnnikaWierichs/some_project
git config credential.helper store git config --global credential.helper 'cache --timeout 7200' # for 2 hours