Start project from scratch
mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin [email protected] :briansaycocie/project_name.git
cd /path/to/my/repo
git init
git remote add origin [email protected] :briansaycocie/project_name.git
git push -u origin --all # pushes up the repo and its refs for the first time
git push -u origin --tags # pushes up any tags
cd /path/to/my/repo
git init
git remote add origin [email protected] :briansaycocie/project_name.git
git fetch origin
git checkout -b master --track origin/master
git update-index --assume-unchanged path/to/file.txt
git update-index --no-assume-unchanged path/to/file.txt
Remove local untracked files from working tree
git clean -n (shows what will be deleted)
git clean -f (deletes files)
git clean -fd (deletes files and directories)
git clean -fX (deletes ignored files)
git clean -fx (deletes ignored and non-ignored files)
Merge feature_branch to master
commit changes in feature_branch
git co master
git merge --no-ff feature_branch
(if push failed) git reset --hard origin/master
git push
git reset --merge ORIG_HEAD
git reset --hard HEAD
git checkout -b new_branch
git fetch && git checkout new_branch
git co feature_branch
git tag archive/feature_branch
git push origin archive/feature_branch
git co master
git branch -d feature_branch
git push origin --delete feature_branch
git branch -D local_branch
git push origin :remote_branch
Configure upstream, git pull short command
git branch --set-upstream-to=origin/< branch>
Fix “your branch is ahead of x by x commits”##
git reset --hard origin/master
Replace local branch with remote branch entirely
git reset --hard origin/master
Bring old feature branch up-to-date with master
git co feature/branch
git rebase master
git remote -v
git remote set-url origin [email protected] :user_name/project_name.git (or git remote rm origin, then git remote add origin git@bitbucket...)
git remote -v
Sync forked repo with master repo