git command line commit

Git has a “staging area” where files need to be added before being committed, you can read an explanation of it here.

So if you make some change and commit directly, you get some message like:

no changes added to commit (use “git add” and/or “git commit -a”)

git-flow

preview

Before you add, you could have done a:

git add -u -n

To check which files you modified and are going to be added (dry run: -n option), and then

git add -u

once you added, another way to preview is:

git diff --cached

add modified files

To commit all the change, you can do any of the following:

git add filename1 filename2

or add all changes (from root path of the project)

git add .

or use the shorthand -a while commiting:

git commit -a -m "message".

or

git commit . -m "save arezzo files"

One other note for SSH

First follow this official link

To use SSH for github to avoid entering username/password, make sure you’re using the SSH one:

ssh://git@github.com/username/repo.git

And NOT the https or git one:

https://github.com/username/repo.git
git://github.com/username/repo.git

You can now validate with just the SSH Key instead of the username and password.

If you need to replace https origin with git one:

git remote set-url git@github.com:Username/Project.git

git reset SHA

first see the history by:

 git log

. Then use the first 7 chars of the SHA code to do reset.

git SHA b7cg6h3

v

git branch

use git branch to see what branch current is in, the * means current.

To create a new branch, just use

git branch BRANCH_NAME

Then switch to the branch with

git checkout BRANCH_NAME

To merge, switch back to master and

git merge BRANCH_NAME

To resolve conflict , just modify the master to the desired status and commit.

To delete a branch

git branch -d BRANCH_NAME

Git Rebase

The major benefit of rebasing is that you get a much cleaner project history

more about rebase vs merge .

 

中文的常用list

 

Leave a comment