Git

From GHER

(Difference between revisions)
Jump to: navigation, search
(Moving files to another repository with history conserved)
(Blanked the page)
 
Line 1: Line 1:
-
Git is a version control system (VCS).
 
-
== Installation ==
 
-
 
-
The procedure is described for Linux, Mac and Windows on the main git documentation:<br>
 
-
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
 
-
 
-
I haven't tested the version on Windows yet.
 
-
 
-
=== Configuration ===
 
-
 
-
==== Display current branch in bash ====
 
-
 
-
To have something like:
 
-
ctroupin@gher13 ~/ULg/DIVA/Diva_python_tools (ReadPlotModule) $
 
-
 
-
add following lines to your ~/.bash_profile
 
-
 
-
parse_git_branch() {
 
-
      git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
 
-
}
 
-
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
 
-
 
-
'''Source:''' https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt<br>
 
-
(but probably also described in the [https://git-scm.com/book/en/v2 reference book]).
 
-
 
-
== Basic commands ==
 
-
 
-
=== General ===
 
-
 
-
The git [https://git-scm.com/book/en/v2 reference book] is extremely well written so most of the issues one might have can be solved by reading the book.<br>
 
-
However it is often easier to type the issue in a google search bar and find the solution in specialized forums.
 
-
 
-
== GitHub ==
 
-
 
-
GitHub is an online project hosting using Git. GHER has now an account on GitHub to store the code and software: https://github.com/gher-ulg <br>
 
-
You need to [https://help.github.com/articles/signing-up-for-a-new-github-account/ create an account in GitHub] in order to be able to contribute to existing codes or to upload yours before the gher-ulg administrator can add you as a member of the organization.
 
-
 
-
[[File:GithubGher.png|500px]]
 
-
 
-
Once that is done, if your code is uploaded in a repository within https://github.com/gher-ulg/, the other members of the organization can directly edit the code.
 
-
 
-
=== Coupling ===
 
-
 
-
Some repositories are also preserved using [https://zenodo.org zenodo].<br>
 
-
This means that every time you create a release (it has to be done through the GitHub webpage, not with the command line), a publication and a DOI will be generated in zenodo (see image below). That release of the code can then be obtained from zenodo and cited properly.
 
-
 
-
[[File:Zenodo example.png|500px]]
 
-
 
-
== Troubleshooting & FAQ ==
 
-
 
-
=== Move the most recent commits to a new branch ===
 
-
 
-
You have performed some changes in the master branch but then decide that these changes should have been inside a new branch:
 
-
git branch newbranch
 
-
git reset --hard hashnumber
 
-
git checkout newbranch
 
-
where ''hashnumber'' is the abbreviated commit hash (see [Viewing the Commit history](https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History))
 
-
'''Source''': http://stackoverflow.com/questions/1628563/move-the-most-recent-commits-to-a-new-branch-with-git
 
-
 
-
=== Modify a file name ===
 
-
 
-
git mv old_name new_name
 
-
'''Source:''' https://git-scm.com/docs/git-mv
 
-
 
-
=== Changing a remote's URL ===
 
-
 
-
You decide that your code should be pushed to another repository or account:<br>
 
-
https://help.github.com/articles/changing-a-remote-s-url/<br>
 
-
Use the command:
 
-
git remote set-url
 
-
 
-
=== Moving files to another repository with history conserved ===
 
-
 
-
Well described here:<br>
 
-
http://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history
 
-
 
-
=== error: failed to push some refs to ===
 
-
 
-
git fetch origin
 
-
# Fetches updates made to an online repository
 
-
git merge origin YOUR_BRANCH_NAME
 
-
# Merges updates made online with your local work
 
-
 
-
'''Source:''' https://help.github.com/articles/dealing-with-non-fast-forward-errors/
 
-
 
-
== Moving a code from SVN to Git ==
 
-
 
-
=== Documentation ===
 
-
 
-
Follow the instructions from https://git-scm.com/book/en/v2/Git-and-Other-Systems-Migrating-to-Git.<br>
 
-
Using a recent version of git might help avoid some errors: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git.<br>
 
-
If you messed up with the author names: https://help.github.com/articles/changing-author-info/.<br>
 
-
 
-
=== Comparison with SVN ===
 
-
 
-
[https://svnvsgit.com/ Subversion vs. Git: Myths and Facts]: list differences between the 2 VCSs.<br>
 
-
As the title says, there are some ''myths'' (and ''hype'') about the tools!
 
-
 
-
== Workflow for Diva development ==
 
-
 
-
=== Small fixes ===
 
-
 
-
When correcting tipos, editing README etc: use the `master`branch.
 
-
 
-
=== Bug fixes ===
 
-
 
-
Create specific branch that will be merged, then deleted.
 

Latest revision as of 13:49, 22 June 2017

Personal tools