git config –global user.name “Aleksander Bekasov” git config –global user.email “alekbekasov@…”
Configuration Check:
git config user.name
git config user.email
git config --global --list
Cloning a Git Repository:
git clone O:\TARGV24\tund1Git
Check User Status:
git status
Creating a Branch / Creating a New Branch:
git branch AleksanderB
Switching Branches:
git checkout AleksanderB
Deleting a Branch:
git branch -d IrinaM
Adding Files:
git add .
Committing Changes with a Comment:
git commit -a -m “name added”
Uploading Changes to the Server:
git push
git push --set-upstream origin AleksanderB
Pull the file added later from the server:
git pull origin main
Creating a New Repo:
git init “repoName”
GitHub Book Link:
Initialize Git in the Current Folder:
git init
Set the Username for the Current Repository:
git config user.name
Stage All New, Modified, and Deleted Files:
git add -A
Check the Compact Version of the Status for Repository:
git status --short
Commit the Updated Files Directly (Skip Staging):
git commit -a -m "New line"
View the Commit History for the Repository:
git log
Show Possible Options for the status Command in Command Line:
git status --help
Show All Git Commands in the Command Line:
git help --all
Create a New Branch Called hello-world:
git branch hello-world
List Existing Branches:
git branch
Switch to the hello-world Branch:
git checkout hello-world
Create and Switch to a New Branch Named hello:
git checkout -b hello
Merge the hello-you Branch with the Current Branch:
git merge hello-you
Remove the hello-you Branch from the Local Repository:
git branch -d hello-you
Add a Remote Repository as an Origin:
git remote add origin https://github.com/x/y.git
pull is a Combination of:
fetchand thenmerge
Fetch All Change History from the Origin for This Branch:
git fetch origin
Merge the Current Branch with the master Branch on Origin:
git merge origin/master
Update the Current Branch from Its Origin Using a Single Command:
git pull origin
Push the Current Branch to Its Default Remote origin:
git push origin
List All Local and Remote Branches of the Current Git:
git branch -a
List Only Remote Branches of the Current Git:
git branch -r
Clone the Repository https://abc.com/x/y.git to Your Local Git:
git clone https://abc.com/x/y.git
Clone the Repository https://abc.com/x/y.git to a Folder Named “newlife”:
git clone https://abc.com/x/y.git newlife
Rename the origin Remote to upstream:
git remote rename origin upstream
In .gitignore, Add a Line to Ignore All .temp Files:
*.temp
In .gitignore, Add a Line to Ignore All Files in Any Directory Named temp:
temp/
In .gitignore, Add a Single Line to Ignore All Files Named temp1.log, temp2.log, and temp3.log:
temp?.log
In .gitignore, Ignore All .log Files Except main.log:
*.log
!main.log
Add a New Remote Named ssh-origin Connecting to x/y.git on abc.com Using SSH:
git remote add ssh-origin git@abc.com:x/y.git
Replace the Remote URL for origin with x/y.git on abc.com Using SSH:
git remote set-url origin git@abc.com:x/y.git
Show the Log of the Repository, Showing Just 1 Line per Commit:
git log --oneline
Revert the Latest Commit:
git revert HEAD
Revert the Latest Commit, Skipping the Commit Message Editor:
git revert HEAD --no-edit
Revert the Two Last Commits:
git revert HEAD~1
Reset to the Commit with the Hash abc1234:
git reset abc1234
Amend the Previous Commit with the Message “Updated index”:
git commit --amend -m "Updated index"