Difference between revisions of "Git commands"

From Vrieze Wiki
Jump to navigation Jump to search
Line 19: Line 19:
 
  git commit -m "message about commit" ## to commit
 
  git commit -m "message about commit" ## to commit
 
  git commit --dry-run -m "message about commit" ## to see what the commit will do first
 
  git commit --dry-run -m "message about commit" ## to see what the commit will do first
 +
</syntaxhighlight>
 +
 +
=Pushing to remote repository (e.g., github.umn.edu)=
 +
The above has only created a repo on your local computer. To push changes to a remote repository, you "push".
 +
<syntaxhighlight lang="bash">
 +
git remote add origin <username>@github.umn.edu/<reponame>.git
 +
git push -u origin master
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 19:19, 18 April 2020

Github is a great place to host code, whether you use it to manage changes, post a final(-ish) version of code, or collaborate and share with others. It can be easier to use git than to email scripts, or point someone to a script on the supercomputer.

Starting a repo

First, you can create a directory (on any computer) and put some files into it. Then to initiate a repo, install git and run something like

git init

Then, to add all the files, run the following (to add specific files just run git add <filename>):

git add .   ## to add all files
git add <filename> ## to add specific files

Finally, to commit the files to the repo, you can run commit

 git commit -m "message about commit" ## to commit
 git commit --dry-run -m "message about commit" ## to see what the commit will do first

Pushing to remote repository (e.g., github.umn.edu)

The above has only created a repo on your local computer. To push changes to a remote repository, you "push".

git remote add origin <username>@github.umn.edu/<reponame>.git
git push -u origin master