-
Notifications
You must be signed in to change notification settings - Fork 63
Git Commands
Dan Ibanez edited this page Aug 25, 2016
·
8 revisions
This page lists common Git commands that SCOREC developers have used. Please review our Git Theory page to help gain an understanding of how Git works before reading this page.
Command | Description |
---|---|
git help |
View summary of common commands |
git help commit |
View documentation about the git commit command |
git init |
Create a new Git repository with the current directory as the source directory |
git clone https://github.com/SCOREC/core.git pumi |
Clone a remote repository, creating source directory pumi
|
git status |
Display a variety of current status info. When in doubt, run this. |
git log |
Show history in a linear fashion with full commit metadata |
git log --oneline --graph --all --decorate |
Show the history graph including where branches point to |
git show abcd123 |
Show all the information about commit abcd123 , including what changes it made |
git add myfile.cpp |
Accept all changes to myfile.cpp into the index. If untracked, start tracking. |
git add --patch myfile.cpp |
Interactively accept some changes into the index. |
git add -u |
Accept all modifications and removals of tracked files into the index. |
git add -A |
Like git add -u , also start tracking all untracked files. |
git commit |
Create a commit from the index, opens environment variable $EDITOR to write commit message |
git commit -m 'Renamed a function' |
Specify the commit message on the command line |
git commit -a |
Same as git add -u followed by git commit
|
git diff |
Show changes between the index and the source directory |
git diff --cached |
Show changes between the index and HEAD
|
git diff --stat |
Summarize differences as number of lines changed |
git branch |
List the local branches |
git branch -vv |
List local branches and what remote branches they track |
git branch api-work |
Create a branch called api-work , by default points to HEAD
|
git checkout api-work |
Switch the current branch to be api-work
|
git merge api-work |
Merge the top commit of the api-work branch into the current branch |
git merge --no-ff api-work |
Same as api-work , but create a merge commit even if fast-forward is possible |
git branch -d api-work |
Delete branch api-work after it is merged |
git branch -D api-work |
Delete branch api-work even if it is not merged |
git fetch origin |
Download the latest state of the origin remote repository |
git merge origin/master |
Merge the latest commit from origin/master into the current local branch |
git pull |
Same as git fetch origin followed by git merge origin/master
|
git push |
Pushes your latest commits to the origin remote, tries to fast-forward origin/master to your master
|
git push origin api-work |
Make your new api-work branch visible at origin ; creates origin/api-work
|
git push -u origin api-work |
Same as git push origin api-work , Also sets api-work to track origin/api-work
|
git push origin --delete api-work |
Remove the branch api-work from the origin remote |
git remote show |
List your remotes |
git remote show origin |
List information about the origin remote: URL, which branches are tracked, etc. |
git remote add core-sim https://github.com/SCOREC/core-sim.git |
Add a new remote called core-sim
|
git cherry-pick abcd123 |
Add a duplicate of commit abcd123 to the current branch |