Steps to use Git commands on the Git Bash command prompt:
1. Create a new folder
2. Right click with mouse on the newly created folder, then you will be prompted with following snap
3. Click on Git Bash Here option
4. Then you will see a new icon displayed on the toolbar as shown below
5. Click on the icon to view the Git Bash window with $ symbol6. Here you go... use the below git commands as per the need
Git commands
Task to Perform |
Description |
Git commands |
Configure
the user name and email address |
Configure
User name and mail ID in repository |
git config --global
user.name "Vasu Chiluveru" git config --global user.email
vasu@chiluveru.com |
Create |
New
local repository |
git init |
Checkout |
In
local working directory |
git clone repositoryURL |
In
remote working directory |
git clone username@host:repositoryURL |
|
Clone
from Branch |
git clone –b <branchname> repositoryURL |
|
When
see any SSL issue while cloning |
git config --global http.sslVerify false |
|
Add file/files to repository |
Add
one |
git add <filename> |
more
files |
git add * |
|
Commit |
Commit
changes to Master |
git commit -m "Commit message" |
Commit
any files you've added or changed |
git commit -a |
|
Push |
Send
changes to the master |
git push origin master |
Status |
List
the files that changed |
git status |
Connect to a remote |
remote
repository |
git remote add origin
<server> |
List
all remote repositories |
git remote -v |
|
Branches |
Switch
to new branch |
git checkout -b <branchname> |
Switch
between branches |
git checkout <branchname> |
|
List
all the branches |
git branch |
|
Delete
the branch |
git branch -d <branchname> |
|
Push
the branch to origin |
git push origin <branchname> |
|
Push
all branches |
git push --all origin |
|
Delete
a branch |
git push origin :<branchname> |
|
|
1. Fetch and merge
changes |
git pull |
2. To merge a different
branch |
git merge <branchname> |
|
3. View all the merge
conflicts the source file |
git diff git diff --base <filename> git diff <sourcebranch> <targetbranch> |
|
4. After resolve any
conflicts, you mark the changed file |
git add <filename> |
|
Tags |
tagging
to mark a significant changeset |
git tag 1.0 <Commit_ID> |
Commit_ID
is the leading characters of the changeset ID |
git log |
|
Push
all tags to origin |
git push --tags origin |
|
|
Have
you mess up, you can replace the changes back |
git checkout --<filename> |
To
drop all your local changes and commits, fetch the latest history |
git fetch origin git reset --hard origin/master |
|
Search |
Search
the working directory |
git grep "foo()" |
Remove |
Remove
any file/s |
git rm /main/src/*.txt |
Move
or Rename |
Move
or rename a file |
git mv oldname newname
|
No comments:
Post a Comment