0% found this document useful (0 votes)
121 views

GIT Commands

The document provides an overview of common Git commands for initializing and managing repositories. It describes commands for initializing a new repository and adding files, committing changes, and pushing to a remote repository. It also covers commands for working with an existing repository, adding and committing changes, resetting to previous commits, stashing changes, merging branches, and tagging commits.

Uploaded by

Thirupati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views

GIT Commands

The document provides an overview of common Git commands for initializing and managing repositories. It describes commands for initializing a new repository and adding files, committing changes, and pushing to a remote repository. It also covers commands for working with an existing repository, adding and committing changes, resetting to previous commits, stashing changes, merging branches, and tagging commits.

Uploaded by

Thirupati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Generic GIT Commands:

For New Repository:


git init
git add README.md or git add .
git commit -m "first commit"
git remote add origin
[email protected]:mavrick202/hello123.git
git push -u origin master

For existing Repository:


rm -rf .git
git init
git remote add origin
[email protected]:mavrick202/hello123.git
git push -u origin master

git add . or git reset -- HARD . /git reset HEAD -- testfile4


git commit
git reset --hard HEAD
git reset --hard commitid
git clean -n
git clean -d -f
git commit --amend
git blame filename
git push --force
git config --global core.editor "nano"
git branch
git checkout -b branch
git branch -D
git stash
git stash save "add style to our site"
git stash list
git stash pop stash@{2}
git merge
git rebase
git rebase -i HEAD~n
git squash

git secrets
git tags
git cherry-pick

===========================================
#!/bin/bash
I=0
mkdir /mygitrepo
touch /mygitrepo/file1
cd /mygitrepo
git init
while [ $I -lt $@ ]; do
echo 'TESTDATA-FROM-SREE-'$I >>file1 && git add .
&& git commit -m COMMIT-$I
I=$(expr $I + 1)
done
I=0

bash script.sh 10

git reset --soft HEAD~1


git reset --hard HEAD~1
git reset --hard origin/branch #This command will sync
the local repository with the remote repository getting
rid of every change you have made on your local.
https://www.atlassian.com/git/tutorials/cherry-pick
git push origin master --force
git reflog
git reflog show --all
git rebase https://www.youtube.com/watch?
v=f1wnYdLEpgI

alias rem='cd .. && rm -rf /mygitrepo/ && cd ~ && bash


commit.sh 10 && cd /mygitrepo'

====================================

You might also like