Last active
March 19, 2020 10:12
-
-
Save b2977053/8212347f966e32a939cc7f9a2c8a3822 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 建立資料夾 | |
mkdir git-branch-demo | |
cd git-branch-demo | |
start . | |
# 建立版本庫 | |
git init | |
# 新增檔案 a.txt 並提交。 | |
echo 'a.txt first commit' > a.txt | |
git add . | |
git commit -m 'a.txt first commit' | |
# 修改檔案 a.txt 並提交。 | |
echo 'a.txt modify' > a.txt | |
git add . | |
git commit -m 'a.txt modify' | |
# 新增分支 newBranch_1 | |
git branch newBranch_1 | |
# 新增檔案 b.txt 並提交。 | |
echo 'b.txt first commit' > b.txt | |
git add . | |
git commit -m 'b.txt first commit' | |
# 新增並切換到該分支 newBranch_2 | |
git checkout -b newBranch_2 | |
# 修改檔案 b.txt 並提交。 | |
echo 'b.txt modify' > b.txt | |
git add . | |
git commit -m 'b.txt modify' | |
# 保留 LOG 資訊 | |
git log --oneline > 'C:\test_Git\LOG.txt' | |
# 刪除 newBranch_1 分支 | |
git checkout master | |
git branch -d newBranch_1 | |
# 復原 newBranch_1 分支 | |
git checkout <commit ID> | |
git branch -b newBranch_1 | |
# 在 newBranch_1 分支,新增檔案並提交。 | |
# git checkout newBranch_1 | |
echo 'Add b.txt in newbranch1' > b.txt | |
git add . | |
git commit -m 'Add b.txt in newbranch1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment