Git Commands
1.
| Git task | Notes | Git commands |
|---|---|---|
| Tell Git who you are | Configure the author name and email address to be used with your commits. Note that Git strips some characters (for example trailing periods) from | git config --global user.name "Sam Smith"
|
2.
| Create a new local repository | In folder | git init |
3.
| Add files | Add one or more files to staging (index): | git add <filename> git add * |
for total stage - git add *
for specific stage - git add <specific path location>
4.
| Commit | Commit changes to head (but not yet to the remote repository): | git commit -m "Commit message" |
5.
| Status | List the files you've changed and those you still need to add or commit: | git status |
6.
| Connect to a remote repository | If you haven't connected your local repository to a remote server, add the server to be able to push to it: | git remote add origin <server> |
7.For New Branch
| Branches | Create a new branch and switch to it: | git checkout -b <branchname> |
8.
| Switch from one branch to another/for branch checkout also: | git checkout <branchname> |
9.
| Push the branch to your remote repository, so others can use it: | git push origin <branchname> |
10.
| Update from the remote repository | Fetch and merge changes on the remote server to your working directory: | git pull |
11.
| To merge a different branch into your active branch: | git merge <branchname> |
12.
| Delete the feature branch: | git branch -d <branchname> |
Comments
Post a Comment