Skip to content

honginho/GitHubTried

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

Learn how to git

Create branch to Github

# clone target repo first and move to the directory
git clone <target_repo>
cd <target_repo_dir>

# create a branch
git checkout -b <branch_name>

#  do something

# COMMIT step
git add .
git commit -m "<commit_details>"

# PUSH step
git push origin <branch_name>

Delete local and remote branch

git branch -d <specific_branch>
git push origin :<specific_branch>

List all branches

git branch

Switch to master or branch

# switch to master
git checkout master

# switch to specific branch
git checkout <specific_branch>

Discard changes

# before add command
git checkout -- <file>

# before commit, after add command
git reset
git checkout -- <file>

(On branch) Revert back to the specific commit and start new commit from it

# check every commit
git log --oneline

# revert back to the specific commit
git checkout <specific_commit_hash>

# remove the latest commit
git revert <latest_commit_hash>

#  do something for new commit

# COMMIT step
# if change something ......
git add .
git commit -m "<commit_details>"
# else ......
git commit -a

# PUSH step
git push origin HEAD:<branch_name> -f

# --------------------------------------------------
#  however, HEAD detached at <detached_commit_hash>
# --------------------------------------------------

# check branch
git branch # || git branch -v

# create a temp branch for the detached HEAD
git branch <tmp_branch_name> <detached_commit_hash>

# checkout and merge temp branch to original branch
git checkout <branch_name>
git merge <tmp_branch_name>

# if conflict then after resolving
git add .
git commit -m "<commit_details>"

git push origin <branch_name> # if on master: git push

About

The operating procedures of GitHub.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published