Just some notes on my experience using Github
I didn’t know it for months lol… Git is a free and open source distributed version control system created by the famous Linux Torvalds, born around 2005. Github was lauched in 2008 by a company (I think) and it is a web platform for git repos.
Saved changes are called commits.
I am still a bit confused but I think you can safely think of HEAD as branch and ref as commit more info
If two people made changes on the same line, for exmaple if one person wrote console.log(‘apple’) and the other wrote console.log(‘banana’) then github wouldn’t know which version to use in the merged file. So in the file, it will look like
<<<<<<< HEAD
console.log('apple')
============
console.log('banana')
>>>>>>> [other/branch/name]".
Now to resolve the conflict, it’s not necessarily an either or scenario. Just delete all the syntax things, and leave whatever you want the final version to be in this branch. It could be that you don’t want either, and so on. After editing, you need to tell git that you’ve resolved the conflict by saving your edits. git add .
It might be a good idea to use a gitmerge tool instead of resolving it in the file editor, which can be clumsy.
and want to just reset things to before the merge “git merge –abort” “git reset –hard “
Why?
From your local terminal, make sure you’re in the repo: git config credential.helper 'cache --timeout=300'
(300 seconds = 5 mins. 10800 seconds = 3 hours) git push
Username: <type your username>
Password: <type your password>
[work for 5 more minutes] $ git push http://example.com/repo.git [your credentials are used automatically] You can provide options via the credential.helper configuration variable (this example drops the cache time to 5 minutes):
$ git config credential.helper ‘cache –timeout=300’
For local branches
git diff form master
Compare local form branch to remote form branch
git diff form origin/form
You need to add and commit for the merge to finish
In local terminal, git config user.name
to check if user name is yours. If not, git config user.name cici-chen
and git config user.email blahbla@balh.com
(must set both!) to set correct username. Then git config user.name
to double check.
From your local computer’s terminal
git clone
to get repo on to your local computercd
into the local foldergit fetch
to see if there is any difference between this local version and the remote version Base branch is the branch that you’re merging things into- If there is difference, and you don’t want to just force merge the local and the remote, you can
git checkout -b refactor
to create a new local branch called refactor, andgit push origin refactor
to push that to remote github. Then go to github.com, and click onnew pull request
, select your refactor as the base (whoever is behind on commits is the base) and master as compare, to see the difference between master and rafactor branch, which is effectively the difference between the remote master branch and your local master branch. If you’re happy with updating your local branch to be identical to remote branch, then you canmerge pull request
to make your remote refactor branch identical to master.- So now your remote refactor branch is up-to-date with your remote master branch, we’re back on local terminal, and we want to pull the things from remote branches into local branches. On local master branch,
git pull origin master
. (To double check, you can performgit fetch
to see if it is indeed up-to-date with remote master branch. Then checkout to local refactor branch,git pull origin refactor
.- Now I’m ready to work on my new refactor branch yay.