Sunday, November 20, 2016

Git create repo commands


First, create a new repo tour-of-heroes-angular on Github

1. Go to the directory you want to create a git repo and from inside the directory issue

git init

2. If first time installing git, issue the following commands
git config --global user.email "yashish@xxx.yyy"
git config --global user.name "yashish"

3. stage files locally

git add .

4. Commit locally
git commit -m "Initial"

5. Add the local repo to the remote repo that was created

git remote add origin https://github.com/yashish/tour-of-heroes-angular.git

6. Optionally verify

git remote -v

[
NOTE: if typo, update url with command
git remote set-url origin https://github.com/yashish/tour-of-heroes-angular.git
]

7. Push changes to local repo to github

git push -u origin master

[
NOTE: if new repo contains some files not in the local repo, you may need to use -f option and overwrite. Do not use -f in team environment.

git push -f origin master

]

8 pull from remote
git pull origin master

9. set up tracking so we can issue just git pull command

git branch --set-upstream-to=origin/master master

--------------------------------------------------------------------------------------------------------

to push an existing repository from the command line

git remote add origin https://github.com/yashish/kendo-button-cli.git
git push -u origin master

or to create a new repository on the command line

echo "# kendo-button-cli" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/yashish/kendo-button-cli.git
git push -u origin master


No comments:

Post a Comment