A.1 Git
Cheat Sheet in different languages
Ultimate Guide of Git and GitHub for R user
Setting up Git:
git config
with--global
option to configure user name, email, editor, etc.Creating a repository:
git init
to initialize a repo. Git stores all of its repo data in the.git
directory.Tracking changes:
git status
shows the status of the repoFile are stored in the project’s working directory (which users see)
The staging area (where the next commit is being built)
local repo is where commits are permanently recorded
git add
put files in the staging areagit commit
saves the staged content as a new commit in the local repo.git commit -m "your own message"
to give a messages for the purpose of your commit.
History
git diff
shows differences between commitsgit checkout
recovers old version of fieldsgit checkout HEAD
to go to the last commitgit checkout <unique ID of your commit>
to go to such commit
Ignoring
.gitignore
file tells Git what files to ignorecat . gitignore *.dat results/
ignore files ending with “dat” and folder “results”.
Remotes in GitHub
A local git repo can be connected to one or more remote repos.
Use the HTTPS protocol to connect to remote repos
git push
copies changes from a local repo to a remote repogit pull
copies changes from a remote repo to a local repo
Collaborating
git clone
copies remote repo to create a local repo with a remote calledorigin
automatically set up
Branching
git check - b <new-branch-name
git checkout master
to switch to master branch.
Conflicts
occur when 2 or more people change the same lines of the same file
the version control system does not allow to overwrite each other’s changes blindly, but highlights conflicts so that they can be resolved.
Licensing
People who incorporate General Public License (GPL’d) software into their won software must make their software also open under the GPL license; most other open licenses do not require this.
The Creative Commons family of licenses allow people to mix and match requirements and restrictions on attribution, creation of derivative works, further sharing and commercialization.
Citation:
- Add a CITATION file to a repo to explain how you want others to cite your work.
Hosting
- Rules regarding intellectual property and storage of sensitive info apply no matter where code and data are hosted.