git command + commit local project code to git gerrit

Combining the integrated git tool in eclipse and the git bash command line installed in windows, the process of submitting code to gerrit is as follows:
1. First update the project code to ensure that the remote branch code is synchronized to the local, then: right-click on the project-->team-->Synchronized Workspace-->Enter the Team Synchronized view interface;

2. Select the file to be submitted-->Right click Add to Index-->Right click commit-->Enter the submission log (note that this corresponds to the requirement ID, such as APP-99999);

3. Push the modified files locally through the git bash command (only the files that were added to the index in the previous step will be affected by the push command), such as: git push origin HEAD:refs/for/20170101
If an error is reported, you may need to refresh the project, then update the project, and then re-execute the push command;


ps:
The branch where the current eclipse project is located: 20170101

1. Update the remote code to the local repository
	git fetch
	git stash
	git rebase origin/20170101
	git stash pop

2. Add the locally modified files to the local repository
	git add D:\.......\hello.java

3. Submit
3.1:
	git commit -m "Commit log description";//commit is to submit the modified content to the local warehouse
3.2:
	git push origin HEAD:refs/for/20170101; //The push command is to submit the content to be submitted in the local warehouse to the remote target warehouse branch
3.3: Modify the submitted comments or code
git commit --amend
//
After git push, how to modify the code or append the code to the same gerrit's changeId commit record can be done in two ways:
Type 1: After eclipse has modified the code, right-click the project in the team synchronizing view and execute the add to index command, and then execute git status to check whether the add is complete (the file is green, indicating that it has been added, and the file is red indicating that it has not been added).
Then execute the git commit --amend command in git, enter: wq to exit the save, and you will find that the additionally modified code has been modified to take effect. Finally, execute the git push origin head:refs/for/20171111 command to submit the code to the remote target branch ;
The second type: After eclipse has modified the code, right-click the project in the team synchronizing view to execute the add to index command, then right-click the project to execute the commit command. Note that the changeId in the comment written at this time should be consistent with the previous one.
Finally, enter git push origin head:refs/for/20171111 in git to submit the code to the remote target branch;
The above two methods can ensure that only one submission record appears on gerrit (the record will show that 2 change operations have been performed).
//
3.4 Conflict resolution
After modifying the conflicting code, in the Team Synchronizing view, find the conflicting file, right-click and select "Mark as Merged".

【Merge branch】
If all the changes are on the origin/dev-20180101 branch, if you want to merge the branch code to the main branch master, perform the following steps:
1. Make sure that all the code has been submitted to the origin/dev-20180101 branch, and recheck out the master branch code to the local;
2、git pull;
3、git merge origin/dev-20180101;
4, the above is enough. If you need to push, refer to: git push origin head:refs/for/master



ps:
refer to the blog
----git delete the files that have been added
http://blog.csdn.net/yang3wei/article/details/9399723

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326940023&siteId=291194637