Summary of git for beginner
How to deal with git?
To clarify, this work flow works depends on your folder dictionary as below:
clone which url?
Red text is your remote host name, that means if you push your edited files, you will push to viztech’s github. Unfortunately you have no permission to push to his github.
If you need to push, it means you need to push to your github, so fork first, and clone with the url comes from your github.
However, you can check your remote host anytime with git remote -v
It will show your remote host name like this:
If you want to rename folder name, you can add blue text after clone url. ‘week-3-classwork’ will be your folder name rather than ‘2016-fall-week-3-assignment’.
Why commit or push failed?
Before you push, you have to commit files these you modified (including edit, add, delete files).if you didn’t commit, you will not push new changes to github.
Before you commit, you have to add files you want to commit to staging area.
However, you can check your files anytime with git status.
If it shows you any red text, as below:
It means there’s a file you edited but didn’t add it to staging area, so you will not commit and push successfully.
After you add, it will show you green text, as below:
Then you can commit it and push.
How to update new code of git repo?
If you’ve already clone a repo of a author from his github, now the author push his new changes to this repo, you may want to update your local codes too.
First, cd 2016-fall-week-3
Go to the folder you want to update. It’s okay if you rename your folder, because it’s not foldar name matter to git, it’s remote host name does.
Then, you need to make sure you clone from his git url. Check with git remote -v
Last, git pull, it will merge his new changes to your local files.