shows both remote and local branches
git branch -a
shows remote branches.
git branch -r
shows local branches
git branch
shows all branches in specific directory
git branch --remote --list 'origin/features/*'
checkout branch from remote
git checkout features/convert-idn-to-utf8-characters
checkout new branch
git checkout -b feature
push new branch to remote of same name
# push this branch to our central repository so it can be shared
# note the -u is to set up your local branch to track origin
git push -u origin feature
stage all removed files
git add -u
revert a modified file
git checkout {file}
revert file from another branch
git checkout <branch_name> -- <paths>
unstage a file, leaving it modified
git reset HEAD {file}
todo
Add existing brand new repo to gitlab: first create your project
Existing folder or Git repository
cd existing_folder
git init
git remote add origin [email protected]:wagena/frontend-dashboard-hackday.git
git add .
git commit
git push -u origin master
recover deleted file that is already commited and pushed
// get the last revision to the file (which is when it was deleted)
git rev-list -n 1 HEAD -- codebase/classes/Account/DisbursementCheck.php
// checkout the version of the file one commit earlier (before it was deleted)
git checkout 44384a5df7d1a596bc658f4b29d0efdc5768fc76^ -- codebase/classes/Account/DisbursementCheck.php
// return to the one before the current revision - effectively making our last commit undone.
// --soft flag: this makes sure that the changes in undone revisions are preserved. After running the command,
// you'll find the changes as uncommitted local modifications in your working copy.
$ git reset --soft HEAD~1
// same as the above but don't keep the changes
git reset --hard HEAD~1