Git Commands

Git is a collection of commands to edit, track and organize gromramming files. It’s particularily useful in version constroling and joint project. Instead of other tools such as Perforce that only keeps copies on cloud, git also have copy/copy management system in local hardware, in addition, copies are also stored and synchronized online with all progressing versions.

$ git config –global user.name “My Name”
$ git config –global user.email myEmail@example.com

cd to the folder to set git, then type
$ git init
then we got this output: Initialized empty Git repository in /home/user/Desktop/git_exercise/.git/

$ git status to check status

$ git add hello.tx (*.py all python files)
$ git add – A (add all files)

$ git commit -m “intial commit” (commited locally)

Now connect to remote warehouse/on cloudserver (it’s called origin)
$ git remote add origin https://github.com/znaixian/weighting.git

$git push origin master
(push to the cloud)

$ git clone https://github.com/znaixian/weighting.git

$ git pull
(pull from the cloud)

reference: https://mp.weixin.qq.com/s/X9sIFYwuOJr0gUwADhWXJA

If there is a repo on Github either created directly or you want to clone from, type

$ git clone https://github.com/znaixian/Python-Application-in-Financial-Modeling-.git

Then we need to create a branch to work on sideline, to be eventually pushed/merged into master folder.

$ git branch working-branch
$ git status
on branch master
your branch is up to date with ‘origin/master’
nothing to commit, working tree clean
$ git branch -a ( to view all the branches)

$ git checkout master
$ git checkout working-branch
to switch between branches.

Normally, we do some update on branch, then we need to push to the github to reflect it.

$ git rm python-index-book.mdgit status
$ git commit -m ‘Got rid of stuff’
$ git add
$ git commit -a
$ git push

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.