Common Git Commands

download Common Git Commands

of 3

Transcript of Common Git Commands

  • 8/3/2019 Common Git Commands

    1/3

    Common Git Commands

    These are most of the commands used in git. The first part called How to

    sync your work with the repositoryis 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

  • 8/3/2019 Common Git Commands

    2/3

    git log --name-only --since='12/10/2009 10:41' --pretty=oneline>filename.txt

    git gui blame cgi-bin/SoapConnect.cgi

    How to get help

    git help

    How to remove a file or directory

    git rm filename git rm directoryr

    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. The filethat has a merge conflict will be displayed in the error.

    Open file that has a merge conflict and find the text that is inconflict. Git will present both sides of the conflict and it is up

    to you to determine what the file should look like. The file will

    have information similar to this.

  • 8/3/2019 Common Git Commands

    3/3

    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(createbranch)

    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)

    Creating a bare repository

    git -bare init

    Here are lines that are either unchanged from the common

    ancestor, or cleanly resolved because only one side changed.