Discuss about merge conflict
You can run into a merge conflict when you commit a change and someone else has made changes to the file. When you face this type of merge conflicts there are two options.
- Clean the file manually
- Open the file using a text editor and modify the conflicting parts of the file that will appear marked with
>>> <<<
. The file won’t be usable unless you edit it to resolve these conflicts. - Then commit and push this new file into the repository.
- Open the file using a text editor and modify the conflicting parts of the file that will appear marked with
- Remove the local copy of the GitHub repository
- Make sure your local clone does not have any other changes you wish to commit.
- This means that is completely safe to get rid of everything you have locally.
- Then remove the local clone and clone a fresh copy from GitHub.
Discuss about “.gitignore”
FIXME: Give examples to exclude tmp files, cache files and large data-sets using wildcard pattern (here is an example).
How to setup github ssh keys to pull and push private repos
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account
How to get around the issue GitHub SSH is blocked by firewall
You will need to use https
. First, generate a GitHub token from your github account control panel – use the classic
personal access tokens and permit it to access all repositories.
Then you will have to clone a repository using https
. For example instead of:
git clone git@github.com:cumc/fungen-xqtl-analysis.git
you will have to run
git clone https://github.com/cumc/fungen-xqtl-analysis.git
and type in your GitHub username and token you generated – you can copy and past the token when prompted for password.
To avoid doing so, you can set this global git option:
git config --global credential.helper store
By doing so, you will not have to type in the login credential every time you pull/push.
Why and how to use git branches and pull request
git branch and pull requests are useful for collaboration with others; but in my view they are even more useful for collaborating with yourself in research setting.
Suppose you want to try something completely different in research — eg some alternative implementation of a computational task that may or may not improve
over existing approach, or an idea you don’t know if it will work. That is when you should create a different git branch
and try things there. If it works
you can send in a pull request to merge the branches so it become officially adopted. Another good thing about branch is that you can compare all at once
differences in your branch from multiple commits so you know what exactly you have changed.
Please search online and learn about using branches and pull request. I suggest you can hold it off until during your research project you run into the scenario I described above. That will be a very good motivating case for you to start learning it
Links to git tutorials
- Intermediate git, a tutorial I find useful to learn git more comprehensively.