New Developers Working Group
git add myfile.txt
–> stage a specific filegit add -A
–> stage all modified files in the current directory and subdirectoriesgit add .
–> (Note the period) stage all modified files in the current directory but not subdirectoriesgit branch
–> list existing local branchesgit branch mynewbranch
–> create a new branchgit branch -m oldbranchname newbranchname
–> change name of branchgit branch -D branchname
–> delete a local branch (cannot delete a branch you currently have checked out, so switch to different branch first)git checkout mybranch
–> check out an existing branchgit checkout -b mynewbranch
–> create a new branch based on your current branch and check it out at the same timegit checkout -b mynewbranch origin/main
–> create a new branch based on your main branch rather than on your currently checked out branchgit checkout main
–> switch to main branchgit checkout – docname.tt2
–> resets a file you've changed back to its original state (like an undo / revert changes command)git cherry-pick <hash>
–> apply a specific commit to your local branchgit cherry-pick -s <hash>
–> apply a specific commit to your local branch with your signoffgit cherry-pick -s <first hash>^..<last hash>
–> apply a range of commits with your signoff to your local branchgit clean -d -i
–> interactively delete untracked files you do not wantgit clean -d -f
–> delete untracked folders you do not wantgit clone git://git.evergreen-ils.org/Evergreen.git
–> clones a remote repositorygit commit
–> invoke the default text editor to add a commit messagegit commit -m "my commit message"
–> add brief commit message instead of opening the text editor to add a commit messagegit commit --amend
–> overwrite your last commit messagegit commit --amend --author='Jon Doe <example@example.com'
–> amend commit authorgit commit --amend --signoff
–> view and amend your sign-off branchgit commit --amend --signoff <hash>
–> view and amend your signoff for a specific commit on your sign-off branchgit commit -a
–> combine the git add and git commit steps into a single step (does not include newly created files)git config --global -l
–> list all global configuration valuesgit config --global keyname "value"
–> create a global valuegit config --global user.email "you@example.com"
–> set your email addressgit config --global user.name "FIRSTNAME LASTNAME"
–> set your namegit fetch --all
–> refresh your local cache from the remote branches (does not download new branches); equivalent to git remote updategit config -e
–> show git configuration filegit fetch working
–> fetches all new branches in the working directorygit help
–> access the built-in Git help documentationgit log
–> lists most recent commits with detailsgit log --name-only</nowiki'' --> lists first line only of most recent commits
* ''git log <nowiki>--oneline
–> lists id plus first line only of most recent commitsgit pull
–> imports all updates from your default remote repo to your default local repo (usually, this is equivalent to 'git pull origin main'); pull is equivalent to doing a fetch followed by a mergegit pull origin main
–> import all updates from remote origin repo to local main repogit pull --rebase origin main
–> rebases (rather than merges) new remote changes to your local repositorygit push working mybranchname
–> push changes to the remote working directorygit push working --delete mybranchname
–> delete a remote branchgit push working --force mybranchname
–> forces an overwrite on your previous branchgit remote -v
–> display remote directoriesgit remote show origin
–> display remote directoriesgit remote update
–> refresh your local cache from the remote branches (does not download new branches); equivalent to git fetch –allgit reset HEAD myfile.txt
–> unstage a file that has already been stagedgit reset --hard
–> reset a current branch to its original stategit reset --hard HEAD
–> remove last commitgit reset --hard HEAD~2
–> remove last 2 commits (increment numeral as needed)git rm badfile.txt
–> delete a file (if the file is being tracked, be sure to add a commit message indicating the file has been deleted)git show <hash>
–> display the commit text and differences of the specified commmitgit show --stat
–> see what your commit will look like before you push itgit status
–> display status of current branchgit version
–> displays the installed version of Gitgitk
–> use this after committing changes but before pushing them to see what will be pushedIf your patch is behind current main, you'll need to rebase it.
You can also use the interactive rebase mode to look at a series of commits:
git rebase -i origin/main
If you need to start over, just rebase again and paste in your original pick list.
If you have multiple commits in your local branch that you'd like to combine:
git rebase -i HEAD~2
(where 2 is the number of commits you wish to combine)git push working user/jdoe/lp1839359_login_select
If you've already pushed multiple commits up to your remote working git repository, you can still combine them:
git push --force working user/jdoe/lp1839359_login_select
Shortens normal commands so you type less:
$ git config alias.co checkout $ git config alias.cp cherry-pick $ git config alias.br branch $ git config alias.ci commit $ git config alias.st status