Cloning a remote repository
$ git clone https://....xyz.git
check history
$ git log
what was the last commit made
$ git show HEAD
$ git show HEAD~1
$ git show
where did the source come from in current git?
$ git remote
origin
whats the remote URL?
$git remote -v
check local branches
$ git branch -r
check remote branches
$ git branch -r
check tags
$ git tag
//TODO add commands to create local repository
whats the remote url for my local repository (will be nothing by default)?
git remote -v
how do I add a remote destination to my repository?
$ git remote add origin https://github.com/bhajanpreets/MyBankBasic.git
(origin is an arbitrary name, I can call it anything)
(you can pull from multiple repositories)
if someone sends a pull request you can add their public repository and pull their changes into your local repository
you can have multiple remotes to evaluate the patches
After adding remote, how do I pull any changes from the remote repository?
$ git fetch
or, if there are multiple remotes I can give the name
$ git fetch origin
now check log to see the difference
$ git log origin/master
to merge code (origin/master is the remote)
$ git merge origin/master
How do I see remote branch that I merged from?
$ git branch -r
Its very common to run
$ git fetch; git merge origin/master
These two steps are combined in git pull
$ git pull
how do I set correspondence between my local branch and remote branch before git pull?
$ git branch --set-upstream master origin/master
or else I can specify correspondence in command itself,
$ git pull origin master
How do I push local changes to remote repository?
$ git status
(to check the local changes)
$ git commit -am
(a is to add file and m is for comment message)
$ git status
(will tell that you need to push)
$ git push
(will ask for user name password)
how do I prevent asking for username and password -- add ssh version of the origin?
$ git remote rm origin
$ git remote -v
$ git remote add origin git@github.com:bhajanpreets/MyBankBasic.git
$ git remote -v
origin git@github.com/bhajanpreets/MyBankBasic.git (fetch)
origin git@github.com/bhajanpreets/MyBankBasic.git (push)
$ git push
(need to generate ssh key first - don't have it yet in bhajanpreets so I am using https)
Now how do I add a new tag?
$ git tag v1.2
or
$ git tag -a v1.2 (to add some message)
and push it to remote
$ git tag -s v1.2 (signed tag to confirm that I added this tag and no one else modified it)
$git push --tags (will push tags)
$ git clone https://....xyz.git
check history
$ git log
what was the last commit made
$ git show HEAD
$ git show HEAD~1
$ git show
where did the source come from in current git?
$ git remote
origin
whats the remote URL?
$git remote -v
check local branches
$ git branch -r
check remote branches
$ git branch -r
check tags
$ git tag
//TODO add commands to create local repository
whats the remote url for my local repository (will be nothing by default)?
git remote -v
how do I add a remote destination to my repository?
$ git remote add origin https://github.com/bhajanpreets/MyBankBasic.git
(origin is an arbitrary name, I can call it anything)
(you can pull from multiple repositories)
if someone sends a pull request you can add their public repository and pull their changes into your local repository
you can have multiple remotes to evaluate the patches
After adding remote, how do I pull any changes from the remote repository?
$ git fetch
or, if there are multiple remotes I can give the name
$ git fetch origin
now check log to see the difference
$ git log origin/master
to merge code (origin/master is the remote)
$ git merge origin/master
How do I see remote branch that I merged from?
$ git branch -r
Its very common to run
$ git fetch; git merge origin/master
These two steps are combined in git pull
$ git pull
how do I set correspondence between my local branch and remote branch before git pull?
$ git branch --set-upstream master origin/master
or else I can specify correspondence in command itself,
$ git pull origin master
How do I push local changes to remote repository?
$ git status
(to check the local changes)
$ git commit -am
(a is to add file and m is for comment message)
$ git status
(will tell that you need to push)
$ git push
(will ask for user name password)
how do I prevent asking for username and password -- add ssh version of the origin?
$ git remote rm origin
$ git remote -v
$ git remote add origin git@github.com:bhajanpreets/MyBankBasic.git
$ git remote -v
origin git@github.com/bhajanpreets/MyBankBasic.git (fetch)
origin git@github.com/bhajanpreets/MyBankBasic.git (push)
$ git push
(need to generate ssh key first - don't have it yet in bhajanpreets so I am using https)
Now how do I add a new tag?
$ git tag v1.2
or
$ git tag -a v1.2 (to add some message)
and push it to remote
$ git tag -s v1.2 (signed tag to confirm that I added this tag and no one else modified it)
$git push --tags (will push tags)
Comments