0% found this document useful (0 votes)
12 views

Git Commands

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Git Commands

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.

html

Git task Notes Git commands

git config --global user.name "Sam Smith"


Tell Git Configure the
who you author name git config --global user.email [email protected]
are and email
address to be
used with your
commits.
Note that
Git strips some
characters (for
example
trailing periods)
from user.name
.

Create a git init


new
local
reposito
ry

Check Create a git clone /path/to/repository


out a working copy of
reposito a local
ry repository:

For a remote git clone username@host:/path/to/repository


server, use:

Add files Add one or git add <filename>


more files to
staging (index): git add *

Commit Commit git commit -m "Commit message"


changes to
head (but not
yet to the
remote
repository):

Commit any git commit -a


files you've
added with git
add, and also
commit any
files you've
changed since
then:

Push Send changes git push origin master


to the master
https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html

branch of your
remote
repository:

Status List the files git status


you've changed
and those you
still need to
add or commit:

Connect If you haven't git remote add origin <server>


to a connected your
remote local repository
reposito to a remote
ry server, add the
server to be
able to push to
it:

List all git remote -v


currently
configured
remote
repositories:

Branche Create a new git checkout -b <branchname>


s branch and
switch to it:

Switch from git checkout <branchname>


one branch to
another:

List all the git branch


branches in
your repo, and
also tell you
what branch
you're currently
in:

Delete the git branch -d <branchname>


feature branch:

Push the git push origin <branchname>


branch to your
remote
repository, so
others can use
it:

Push all git push --all origin


branches to
https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html

your remote
repository:

Delete a git push origin :<branchname>


branch on your
remote
repository:

Update Fetch and git pull


from the merge changes
remote on the remote
reposito server to your
ry working
directory:

To merge a git merge <branchname>


different
branch into
your active
branch:

View all the git diff


merge
conflicts: git diff --base <filename>
View the git diff <sourcebranch> <targetbranch>
conflicts
against the
base file:

Preview
changes,
before
merging:

After you have git add <filename>


manually
resolved any
conflicts, you
mark the
changed file:

Tags You can use git tag 1.0.0 <commitID>


tagging to
mark a
significant
changeset,
such as a
release:

CommitId is the git log


leading
characters of
the changeset
https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html

ID, up to 10,
but must be
unique. Get the
ID using:

Push all tags to git push --tags origin


remote
repository:

Undo If you mess up, git checkout -- <filename>


local you can
changes replace the
changes in
your working
tree with the
last content in
head:
Changes
already added
to the index, as
well as new
files, will be
kept.

Instead, to drop git fetch origin


all your local
changes and git reset --hard origin/master
commits, fetch
the latest
history from
the server and
point your local
master branch
at it, do this:

Search Search the git grep "foo()"


working
directory
for foo():

You might also like