- Working with Branches
- Creating and applying patches
- Set up your project to be shared
- Tagging the repo
- Using Vim Fugitive
- Have Git Remember Your UserName
- Update all submodules with:
git submodule foreach 'git pull'
Last active
May 12, 2017 17:30
-
-
Save ebot/305849 to your computer and use it in GitHub Desktop.
git cheat_sheet
Replace proj with the location of your project directory.
git clone --bare ~/proj proj.git
touch proj.git/git-daemon-export-ok
- Create the remote branch:
git push origin origin:refs/heads/new_feature_name
- Make sure everything is up-to-date:
git fetch origin
- Then you can see that the branch is created:
git branch -r
- Start tracking the new branch:
git checkout --track -b new_feature_name origin/new_feature_name
- Make sure everything is up-to-date:
git pull
- After meging back to master, delete the remote branch:
git push origin :heads/new_feature_name
When you get to another computer or clone the git repository to a new computer, then you just need to start tracking the new branch again.
git branch -r
to show all the remote branches- start tracking the remote branch locally
git checkout --track -b new_local_branch_name_ origin/remote_branch_name
- Create a patch for the entire branch against master
git format-patch master --stdout > name_of_your.patch
- Create a patch for the last x commits
git format-patch -x
- Find out the statistics on this patch that you will be applying:
git apply --stat name_of_your.patch
- Test the patch to make sure there are no errors:
git apply --check name_of_your.patch
- With no errors, you can sign off and apply the patch:
git am --signoff < name_of_your.patch
Setting up your project to be shared
- Clone your project to a bare version
git clone --bare ~/proj proj.git
- Set the daemon export flag
touch proj.git/git-daemon-export-ok
- Tag and sign latest update
git tag -s -m "message about tag or release." tag_name
- List tags
git tag -l -n1
- Verify the signature
git tag -v tag_name
- Pushing tags to remote repo
git push origin —tags
- Deleting tags
- Local
git tag -d tag_name
- Remote
git push origin :refs/tags/tag_name
- Local
- Checkout a specific tag for troubleshooting
git reset --hard tag_name_here
- Return to the latest code from a tag"
git reset --hard origin/master
Command | Description |
---|---|
:Glog | history |
:Glog -- % | history for current file |
:copen | open history navifation pane |
Add the following so that you do not have to enter your username when interacting with the specified URL:
[credential "https://github.com"]
username = (MyUsername)
To have git remember your password, follow these instructions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment