Git basic

I’m a noob in using Git, and I’m using Github to host some of the code I wrote. Here are some basic commands to host a project with Github (or using Git revision control generally) (sometimes I forgot the command or the order of which command goes first)

Global setup:

Set up git

git config --global "Your Name"
git config --global

Next steps:

mkdir project-name
cd project-name
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin
git push -u origin master

Existing Git Repo?

cd existing_git_repo
git remote add origin
git push -u origin master

To commit changes (and optionally push changes to Github)

git add .
git commit -m 'commit message'
git push -u origin master

Common SVN users may find it confusing when using Git. Here’s some of the tips:

  • There are no centralized server or repo. You are the server / repo
  • In SVN, what’s in your computer is working copy and the center for committing changes is the repository, In Git,¬†your working copy is your repository.
  • In SVN, project members checked out a working copy and commit changes to a centralized repository. In Git, everyone in a project can be the repository, can checkout (pull) and commit (push) changes to each other
    (Note: In Git, ‘checkout’ is called `pull`, ‘commit’ is saving changes to your own repository, ‘push’ is sending and merging changes to remote repository

Leave a Reply

Your email address will not be published. Required fields are marked *