Common Git Commands
Common Git Commands
These are most of the commands used in git. The first part called How to sync your work with the repository is used most frequently. Note: Please do not push code that is not functional to the repository.
Name and Email address git config -global user.name John Doe git config -global user.email [email protected]
How to sync your work with the repository git status git add . git commit myour description of change git pull -rebase git push git status
How to create or recreate your local repository git clone //servername/html$/eFormRepo . git config push.default tracking
How to determine what has changed git status git diff git diff -stat git log git log --name-only --since='12/10/2009 10:41' --pretty=oneline
git log --name-only --since='12/10/2009 10:41' -pretty=oneline>filename.txt git gui blame cgi-bin/SoapConnect.cgi
How to move a file or directory git mv source_filename destination_filename git mv source_directory destination_directory git mv source_filename destination_filename n (dry run)
How to handle a merge conflict During a git pull -rebase you encounter merge conflict. that has a merge conflict will be displayed in the error. Open file that has a merge conflict and find the text that is in conflict. Git will present both sides of the conflict and it is up The file will The file
to you to determine what the file should look like. have information similar to this.
Here are lines that are either unchanged from the common ancestor, or cleanly resolved because only one side changed. <<<<<<< yours:sample.txt Conflict resolution is hard; let's go shopping. ||||||| Conflict resolution is hard. ======= Git makes conflict resolution easy. >>>>>>> theirs:sample.txt And here is another line that is cleanly resolved or unmodified.
git add filename (this is the name of the conflicted file) git rebase -continue
Working with Branches git push origin origin:refs/heads/vendor_interface_tracking (create branch) git fetch origin (bring changes) git branch r (display remote branches) git checkout -track b vendor_interface_tracking origin/vendor_interface_tracking (one time only per branch) git checkout vendor_interface_tracking (work on branch) git checkout master (back to master) git push origin :heads/vendor_interface_tracking (remove branch)