Skip to main content

git Cheat Sheet

Create a Local Branch from An Upstream Branch

git fetch upstream $REMOTE_BRANCH:$REMOTE_BRANCH

Set the origin URL

git remote set-url origin git@github.com:nikhilbhardwaj/abc.git

Remove file from cache

git rm --cached file1.txt

Creating a feature branch\task

git checkout -b new-feature
git status
git add <some-file>
git commit
git push -u origin new-feature

Merging feature branch with master

git checkout master
git pull origin master
git merge new-feature
git push origin master

Stage any changes to tracked files and commit them in one step

git commit -a -m "COMMIT MSG"

Updating from remote

retrieve latest metadata from remote

git fetch

retrieve latest metadata AND transfer the files

git pull